<%@page contentType="text/html; charset=utf-8"%>
<%@ include file="/commons/taglibs.jsp"%>
<%@ include file="/commons/commonEdit.jsp"%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title></title>
<script language="JavaScript" src="${ctx}/scripts/common/prototype.js"></script>
<script type="text/javascript" src="${ctx}/scripts/common.js"></script>
<script type="text/javascript">
   var thingEntrustId = null;
    var pageNO = null;
   function openThingEntrust(){
   		var url = "${ctx}/thing_thingEntrustAction.do?method=initThingEntrustAdd";
		top.windowOpen(url, 'houseChoose', '${key.add}', 450, 550, true, "houseChoose");
   }
   function openThingEntrustEdit(){
   		if(thingEntrustId == null){
			ErrorAlert("${key.tipsByModify}");
		}
		else{
			var url = "${ctx}/thing_thingEntrustAction.do?method=checkThingEntrustEdit&id="+thingEntrustId;
			new Ajax.Request(url,{method: 'post' ,onSuccess : function(response){
				if(response.responseText == 'false'){
					Alert('存在物品归还记录不允许修改！');
					}
				else{
				var url = "${ctx}/thing_thingEntrustAction.do?method=initThingEntrustEdit&id="+thingEntrustId;
		        top.windowOpen(url, 'houseChoose', '${key.modify}', 450, 550, true, "houseChoose");
				}
			}});
		}
   }
   function showThingEntrustDelete(){
		if( thingEntrustId == null ){
			ErrorAlert('${key.tipsByDelete}');
		}else{
		    var url = "${ctx}/thing_thingEntrustAction.do?method=checkThingEntrustDelete&id="+thingEntrustId;
			new Ajax.Request(url,{method: 'post' ,onSuccess : function(response){
				if(response.responseText == 'false'){
					Alert('存在物品归还记录不允许删除！');
					}
				else{
				  AlarmConfirm('${key.tipsByDeleteConfirm}',"thingEntrustBaseMain","deleteThingEntrust");
				}
			}});

		}
	}
	function deleteThingEntrust(){
		var url="${ctx}/thing_thingEntrustAction.do?method=deleteThingEntrust";
		var param = "id="+thingEntrustId;
		var myAjax = new Ajax.Request(
	                   url,
	                   {method: 'post', parameters:param , onComplete: showResponseDelete}
	                   );
	}
	function showResponseDelete(transport){
		ajaxSubmitException(transport.responseText);
		if(transport.responseText=="false"){
			FailureAlert('${key.doFalse}');
		}else{
			reloadThingEntrust();
		}
	}
   function showDetail(){
   		var url = "${ctx}/thing_thingEntrustAction.do?method=getThingEntrustDetail&id="+thingEntrustId;
		top.windowOpen(url, 'houseChoose', '物品托管', 530, 550, true, "houseChoose");
   }
   function openThingGiveback(){
   		var url = "${ctx}/thing_thingEntrustAction.do?method=initThingGiveback&thingEntrustId="+thingEntrustId;
		top.windowOpen(url, 'thingGiveback', '${key.add}', 300, 550, true, "thingGiveback");
   }
   function reloadThingEntrust(pageIndex){
        thingEntrustId = null;
        reLoadIFrameListWithQuery();
        if(pageIndex != null){
        	pageNO = pageIndex;
        }
		$('thingEntrustList').src="${ctx}/thing_thingEntrustAction.do?method=thingEntrustList&isShowMenu=true&ec_p="+pageNO;
	}
	function reLoadIFrameListWithQuery(){
		window.frames("thingEntrustList").freshFrame();
	}
	function setThingEntrustId(id){
		thingEntrustId = id;
	}
</script>
</head>
<body>
			  <table width="100%" border="0" cellpadding="0" cellspacing="0"   class="tab_line">
			    <tr>
			      <td class="bg_toolBar"><table width="100%" border="0" cellspacing="0" cellpadding="0">
			        <tr>
			          <td align="right">
						<!--------------------------右边图标01----------------------------------->
						<table border="0" cellpadding="0" cellspacing="0" id="ico1">
						  <tr>
						  <pms:AuthTag authName="thing_thingEntrustAction.do?method=initThingEntrustAdd">
						    <td class="toolbarico"><a href="#"  onClick="openThingEntrust();return false;" onFocus="this.blur()"><img src="${ctx}/images/ico_newfile.gif" border="0" align="absbottom" alt="新建" /></a></td>
						    </pms:AuthTag>
						    <pms:AuthTag authName="thing_thingEntrustAction.do?method=initThingEntrustEdit">
						    <td class="toolbarico"><a href="#"  onClick="openThingEntrustEdit();return false;" onFocus="this.blur()"><img src="${ctx}/images/ico_amend.gif" border="0" align="absbottom" alt="修改" /></a></td>
						    </pms:AuthTag>
						    <pms:AuthTag authName="thing_thingEntrustAction.do?method=deleteThingEntrust">
						    <td class="toolbarico"><a href="#" onClick="showThingEntrustDelete();return false;" onFocus="this.blur()"><img src="${ctx}/images/ico_delete.gif" alt="删 除" width="16" height="16" border="0" align="absbottom" /></a></td>
						    </pms:AuthTag>
						    <td  class="toolbarico">&nbsp;</td>
						  </tr>
						</table>
						</td>
        			</tr>
      				</table>
      				</td>
    			</tr>
    			<tr>
			      <td valign="top">
			      	<iframe src="${ctx}/thing_thingEntrustAction.do?method=initThingEntrustList" name="thingEntrustList" id="thingEntrustList" width="100%" height="400px" frameborder="0" scrolling="auto"> </iframe>
			      </td>
			    </tr>
			  </table>

</body>
</html>
